# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: http://doc.scrapy.org/topics/item-pipeline.html

import MySQLdb
from scrapy import log
from settings import *

class FinspiderPipeline(object):
    def __init__(self):
        #conn=MySQLdb.connect(host=db_host,port=db_port,user=db_user,passwd=db_passwd,db=db_db,charset=db_charset)
        #cursor = conn.cursor()
        log.msg("PIPE kom", level=log.WARNING)
        pass

    def process_item(self, item, spider):
        log.msg("PIPE kom", level=log.WARNING)
        sql = "insert into products (bank,prdname,begindate,enddate,expiredate,type,source values(%s,%s,%s,%s,%s,%s,%s)" % (item["bank"],item["prdname"],item["begindate"],item["enddate"],item["expiredate"],item["type"],item["source"])
        return item
